package com.example.project.controller;

import com.example.project.entity.Role;
import com.example.project.service.IRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 作者：金照富
 * 2023年10月31日
 */
@RestController
@Api
public class RoleController {
    @Autowired
    private IRoleService roleService;

    @ApiOperation(value = "添加角色类型")
    @RequestMapping("/insertRole")
    public int insertRole(Role role){
        return roleService.insertRole(role);
    }

    @ApiOperation(value = "删除角色类型")
    @RequestMapping("/deleteRole")
    public int deleteRole(int id){
        Role role=new Role();
        role.setRoleId(id);
        return roleService.deleteRole(role);
    }

    @ApiOperation(value = "修改角色类型信息")
    @RequestMapping("/updateRole")
    public int updateRole(Role role){
        return roleService.updateRole(role);
    }

    @ApiOperation(value = "查询所有角色类型信息")
    @RequestMapping("/getAllRole")
    public List<Role> getAllRole(Role role){
        return roleService.getAllRole(role);
    }

    @ApiOperation(value = "查询角色类型信息")
    @RequestMapping("/getRole")
    public Role getRole(int id){
        Role role=new Role();
        role.setRoleId(id);
        return roleService.getRole(role);
    }
}
